package org.wevil.repo;

import org.wevil.entity.cond.CondRoleSubject;
import org.wevil.entity.pk.PKCondRoleSubject;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface CondRoleSubjectRepo extends BaseRepo<CondRoleSubject, PKCondRoleSubject>{

    @Query(value = "select subject_id from cond_role_subject where role_id = ?1", nativeQuery = true)
    List<Integer> findSubjectIdByRoleId(int roleId);

    @Query(value = "select subject_id from cond_role_subject where role_id in ?1", nativeQuery = true)
    List<Integer> findSubjectIdByRoleIdIn(List<Integer> roleId);

    @Modifying
    void deleteByRoleId(int roleId);

    @Modifying
    void deleteBySubjectId(int menuId);
}
